<template>
  <div class="page">
    <div class="weui-cells success_top">
      <div class="weui-cell">
          <div class="weui-cell__bd success_top_con">
            <img src="../../../static/images/ic_cg.png" mode="widthFix">
            <div>账户充值</div>
            <div>+{{result.tranAmount}}</div>
          </div>
      </div>
    </div>
    <div class="weui-cells">
      <div class="weui-cell">
          <div class="weui-cell__bd order_info">
            <div class="weui-flex">
              <div class="weui-flex__item">订单编号：</div>
              <div>{{result.orderNo}}</div>
            </div>
            <div class="weui-flex">
              <div class="weui-flex__item">支付类型：</div>
              <div>{{result.lineType==0?'线下支付':result.lineType==1?'线上支付':'无'}}</div>
            </div>
            <div class="weui-flex">
              <div class="weui-flex__item">支付状态：</div>
              <div>支付成功</div>
            </div>
            <div class="weui-flex">
              <div class="weui-flex__item">支付方式：</div>
              <div>微信</div>
            </div>
            <div class="weui-flex">
              <div class="weui-flex__item">订单来源：</div>
              <div>小程序</div>
            </div>
            <div class="weui-flex">
              <div class="weui-flex__item">充值日期：</div>
              <div>{{result.tranTime}}</div>
            </div>
          </div>
      </div>
    </div>
	<div class="footer weui-flex">
	  <mp-button type="default" size="large" btnClass="mb15" @click="goHome()">返回首页</mp-button>
	</div>
  </div>
</template>

<script>
     import * as appId from "@/utils/util"
     import {toDecimal2} from "@/utils/util"
     import {getTIme} from "@/utils/util"
     import mpButton from 'mpvue-weui/src/button';
export default {
  data () {
    return {
      orderId:"",
      phone:"",
      userId:"",
      timer:"",
      listLabel:[{
        name:"门店",
        value:1
      },{
        name:"小程序",
        value:2
      },{
        name:"公众号",
        value:3
      },{
        name:"微商城",
        value:4
      }],
      paySource:[{
        name:"pos销售支付(线下)",
        value:1
      },{
        name:"微信线上支付",
        value:2
      },{
        name:"支付宝线上支付",
        value:3
      }],
      result:{}
    }
  },
  onLoad(option){
    this.orderId=option.id;
  },
  components:{
    mpButton
  },
  onShow(){
    wx.setNavigationBarTitle({
      title: "充值成功"
    })
    this.userInfo =wx.getStorageSync('userInfo')&&JSON.parse(wx.getStorageSync('userInfo'))
    if(this.userInfo) {
      this.phone=this.userInfo.mobileNo;
      this.userId=this.userInfo.baseUserId;
      wx.showLoading({
        title: '加载中',
      })
      this.timer=setInterval(()=>{
        this. getDetail()
      },1000)




    }else{
      wx.showToast({
        title:'请先登录',
        icon: 'none',
        duration: 2000
      })
    }
  },
  methods: {
    goHome(){
      let url="/pages/index/main"
        mpvue.switchTab({ url })
    },
    getDetail(){
      this.$http.request({
                method:"post",
                url:"/v1.0/appletHome/getRechargeOrder",
                body:{
                 	"appid":appId.appId,
                 	"phone":this.phone,
                 	"productId":this.orderId,

                }
      }).then((data)=>{
        if(data.code==0){
          if(data.result!='处理中'){
            clearInterval(this.timer)
            wx.hideLoading()
            this.result=data.result;
            this.result.ftranAmount=toDecimal2(this.result.ftranAmount)
            this.result.tranTime=getTIme(this.result.orderTime)
          }else{

          }

        }
      })
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
  .share .weui-flex{
    padding: 0.5em 0;
    width: 50%;
    float: left;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    text-align: left;
  }
.success_top{
  font-size: 0.8em;
  text-align: center;
  margin-top: 0px!important;
}
.success_top .success_top_con{
  padding: 1em 0;
}
.success_top img{
  width: 4em;
}
.order_info{
  font-size: 0.9em;
}
.order_info .weui-flex__item{
  color: #999;
}
</style>
